<?php
namespace app\home\controller;
use cmf\controller\UserBaseController;
use think\Db;

class SupplyController extends UserBaseController
{
    //查看流水应该是分权限的，暂时没有加
    function _initialize()
    {
        parent::_initialize();
    }
    public function index()
    {       
       /**搜索条件**/
       $uinfo=cmf_get_current_user();
        //dump($uinfo);
       $param = $this->request->param();
       $where=array();
       $starttime=isset($param['start_time'])?$param['start_time']:'';
       $endtime=isset($param['end_time'])?$param['end_time']:'';
       if(!empty($starttime)){
        	$where['ctime'][]=array('egt',strtotime($starttime));
       }
       if(!empty($endtime)){
        	$where['ctime'][]=array('lt',24*60*60+strtotime($endtime));
       }                     
       if(!empty($uinfo['id'])){
        	$where['operatorid']=$uinfo['id'];
       }
       //判断登陆者权限
//        if($uinfo['user_type'] == 3){
//            $store_list=Db::name('Store')->where(array('steer'=>$uid))->field('id')->select()->toarray();
//            foreach($store_list as $k=>$v)
//            {
//                 $new_list[] = $v['id'];
//            }
//            $string=implode(',',$new_list);
//            $where['storeid']=array('in',$string);
//        }
       $list=Db::name('Supply')->where($where)->order("id DESC")->paginate(10);
       $page = $list->render();
       $this->assign("page", $page);
       $this->assign("list", $list);
       $this->assign("uinfo", $uinfo);
       return $this->fetch();
    }
    
}